﻿<%@ Page MasterPageFile="~/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="CatalogCargo.aspx.cs" Inherits="DigDes.DSchool.SUPS.Web.UI.CatalogCargo" %>


<asp:Content runat="server" ContentPlaceHolderID="MainContent">

    <html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <div>  
        &nbsp;&nbsp;<asp:ScriptManager ID="ScriptManager1" runat="server">
         </asp:ScriptManager>

        <asp:ObjectDataSource ID="CargoODS" runat="server" SelectMethod="GetCargoCatalogPage" StartRowIndexParameterName="startRowIndex" MaximumRowsParameterName="maximumRows"  SelectCountMethod="GetCargoAmount" TypeName="DigDes.DSchool.SUPS.DataAccess.Database.CargoDAC" EnablePaging="true" OnLoad="CargoODS_Load">
             <SelectParameters>
                    <asp:Parameter Name="startRowIndex" Type="Int32" DefaultValue="0" />
                    <asp:Parameter Name="maximumRows" Type="Int32" DefaultValue="10" />
                </SelectParameters>
        </asp:ObjectDataSource>



        &nbsp;<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:GridView 
                    ID="GridView1" 
                    runat="server" 
                    AutoGenerateColumns="False" 
                    DataSourceID="CargoODS" 
                    DataKeyNames="Code" 
                    OnSelectedIndexChanged="GridView1_SelectedIndexChanged" 
                    UseAccessibleHeader="true" 
                    CssClass="grid-view" 
                    OnSelectedIndexChanging="GridView1_SelectedIndexChanging" 
                    AllowPaging="true" 
                    PageSize="4" 
                    OnPageIndexChanging="GridView1_PageIndexChanging" 
                    OnPageIndexChanged="GridView1_PageIndexChanged"
                    Width="1280" 
                    OnRowDataBound="GridView1_RowDataBound"
                     SelectedRowStyle-CssClass="selectedItem-row" >
                    
                    <PagerStyle CssClass="grid-view-pagination" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />

                        <asp:BoundField DataField="CargoID" HeaderText="ID" SortExpression="CargoID" Visible="false" />
                        <asp:BoundField DataField="CargoName" HeaderText="Груз" SortExpression="CargoName" />
                        <asp:BoundField DataField="Description" HeaderText="Описание груза" SortExpression="Description" />
                        <asp:BoundField DataField="Code" HeaderText="Код груза" SortExpression="Code" />
                        <asp:BoundField DataField="CodeETSNG" HeaderText="Код груза в ETSNG" SortExpression="CodeETSNG" />
                        <asp:BoundField DataField="CargoETSNGName" HeaderText="Название груза в ETSNGN" SortExpression="CargoETSNGName" />
                        <asp:BoundField DataField="CodeGNG" HeaderText="Код груза в GNG" SortExpression="CodeGNG" />
                        <asp:BoundField DataField="CodeGNGName" HeaderText="Название груза в GNG" SortExpression="CodeGNGName" />
                        <asp:BoundField DataField="Mnemocode" HeaderText="Мнемокод" SortExpression="Mnemocode" />
                        <asp:TemplateField HeaderText="Изображение">
                            <ItemTemplate>
                                <asp:Image ID="Image1" runat="server"
                                ImageUrl='<%# "ImageHandler.ashx?CargoID=" + Eval("CargoID")%>'/>
                            </ItemTemplate>
                        </asp:TemplateField>

                    </Columns>
                </asp:GridView>

        <br />
        <asp:Button ID="_addBtn" runat="server" Text="Добавить" OnClick="_addBtn_Click" CssClass="button"/>
        &nbsp;
        <asp:Button ID="_editBtn" runat="server" Text="Редактировать" OnClick="_editBtn_Click"  CssClass="button"/>
        &nbsp;
        <asp:Button ID="_deleteBtn" runat="server" Text="Удалить" OnClick="_deleteBtn_Click"  CssClass="button"/>
        
        <br />
        <h2><asp:Label ID="_stateLbl" runat="server"></asp:Label></h2>


                            
                <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" DataSourceID="CargoDetailODS" AutoGenerateRows="False" DataKeyNames="Code" CssClass="details-view" FieldHeaderStyle-ForeColor="Gray">
                    <Fields>

                        <asp:TemplateField  HeaderText ="Груз" >

                            <ItemTemplate>
                                <asp:Label ID="CargoNameLbl" runat="server" Text ='<%# Eval("CargoName") %>' CssClass="label"></asp:Label>
                            </ItemTemplate>

                            <InsertItemTemplate>
                                <asp:TextBox ID ="InsertCargoNameTB" runat="server" Text='<%# Bind("CargoName") %>' CssClass="text-box"></asp:TextBox>
                            </InsertItemTemplate>

                            <EditItemTemplate>
                                <asp:TextBox ID ="EditCargoNameTB" runat="server" Text='<%# Bind("CargoName") %>' CssClass="text-box"></asp:TextBox>
                            </EditItemTemplate>
                
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText ="Описание груза">

                            <ItemTemplate>
                                <asp:Label ID="DescriptionLbl" runat="server" Text ='<%# Eval("Description") %>' CssClass="label"></asp:Label>
                            </ItemTemplate>

                            <InsertItemTemplate>
                                <asp:TextBox ID ="InsertDescriptionTB" runat="server" Text='<%# Bind("Description") %>' CssClass="text-box"></asp:TextBox>
                            </InsertItemTemplate>

                            <EditItemTemplate>
                                <asp:TextBox ID ="EditDescriptionTB" runat="server" Text='<%# Bind("Description") %>' CssClass="text-box"></asp:TextBox>
                            </EditItemTemplate>

                        </asp:TemplateField>

                        <asp:TemplateField HeaderText ="Код груза">

                            <ItemTemplate>
                                <asp:Label ID="CodeLbl" runat="server" Text ='<%# Eval("Code") %>' CssClass="label"></asp:Label>
                            </ItemTemplate>

                            <InsertItemTemplate>
                                <asp:TextBox ID ="InsertCodeTB" runat="server" Text='<%# Bind("Code") %>' CssClass="text-box"></asp:TextBox>
                            </InsertItemTemplate>

                            <EditItemTemplate>
                                <asp:TextBox ID ="EditCodeTB" runat="server" Text='<%# Bind("Code") %>' CssClass="text-box"></asp:TextBox>
                            </EditItemTemplate>

                        </asp:TemplateField>

                        <asp:TemplateField HeaderText ="Код груза в ETSNG">

                            <ItemTemplate>
                                <asp:Label ID="CodeETSNGLbl" runat="server" Text ='<%# Eval("CodeETSNG") %>' CssClass="label"></asp:Label>
                            </ItemTemplate>

                            <InsertItemTemplate>
                                <asp:TextBox ID ="InsertCodeETSNGTB" runat="server" Text='<%# Bind("CodeETSNG") %>' CssClass="text-box"></asp:TextBox>
                            </InsertItemTemplate>

                            <EditItemTemplate>
                                <asp:TextBox ID ="EditCodeETSNGTB" runat="server" Text='<%# Bind("CodeETSNG") %>' CssClass="text-box"></asp:TextBox>
                            </EditItemTemplate>

                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Название груза в ETSNGN">

                            <ItemTemplate>
                                <asp:Label ID="CargoETSNGNameLbl" runat="server" Text ='<%# Eval("CargoETSNGName") %>' CssClass="label"></asp:Label>
                            </ItemTemplate>

                            <InsertItemTemplate>
                                <asp:TextBox ID ="InsertCargoETSNGNameTB" runat="server" Text='<%# Bind("CargoETSNGName") %>' CssClass="text-box"></asp:TextBox>
                            </InsertItemTemplate>

                            <EditItemTemplate>
                                <asp:TextBox ID ="EditCargoETSNGNameTB" runat="server" Text='<%# Bind("CargoETSNGName") %>' CssClass="text-box"></asp:TextBox>
                            </EditItemTemplate>

                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Код груза в GNG">

                            <ItemTemplate>
                                <asp:Label ID="CodeGNGLbl" runat="server" Text ='<%# Eval("CodeGNG") %>' CssClass="label"></asp:Label>                      
                            </ItemTemplate>

                            <InsertItemTemplate>
                                <asp:TextBox ID ="InsertCodeGNGTB" runat="server" Text='<%# Bind("CodeGNG") %>' CssClass="text-box"></asp:TextBox>
                            </InsertItemTemplate>

                            <EditItemTemplate>
                                <asp:TextBox ID ="EditCodeGNGTB" runat="server" Text='<%# Bind("CodeGNG") %>' CssClass="text-box"></asp:TextBox>
                            </EditItemTemplate>

                        </asp:TemplateField>   

                        <asp:TemplateField HeaderText ="Название груза в GNG">

                            <ItemTemplate>
                                <asp:Label ID="CodeGNGNameLbl" runat="server" Text ='<%# Eval("CodeGNGName") %>' CssClass="label"></asp:Label>                        
                            </ItemTemplate>

                            <InsertItemTemplate>
                                <asp:TextBox ID ="InsertCodeGNGNameTB" runat="server" Text='<%# Bind("CodeGNGName") %>' CssClass="text-box"></asp:TextBox>
                            </InsertItemTemplate>

                            <EditItemTemplate>
                                <asp:TextBox ID ="EditCodeGNGNameTB" runat="server" Text='<%# Bind("CodeGNGName") %>' CssClass="text-box"></asp:TextBox>
                            </EditItemTemplate>
                        </asp:TemplateField> 

                        <asp:TemplateField HeaderText="Мнемокод">

                            <ItemTemplate>
                                <asp:Label ID="MnemocodeLbl" runat="server" Text ='<%# Eval("Mnemocode") %>' CssClass="label"></asp:Label>                       
                            </ItemTemplate>

                            <InsertItemTemplate>
                                <asp:TextBox ID ="InsertMnemocodeTB" runat="server" Text='<%# Bind("Mnemocode") %>' CssClass="text-box"></asp:TextBox>
                            </InsertItemTemplate>

                            <EditItemTemplate>
                                <asp:TextBox ID ="EditMnemocodeTB" runat="server" Text='<%# Bind("Mnemocode") %>' CssClass="text-box"></asp:TextBox>
                            </EditItemTemplate>

                        </asp:TemplateField> 

                    </Fields>

                </asp:DetailsView>

                <br />
                <br />
                <asp:Button ID="_saveBtn" runat="server" OnClick="_saveBtn_Click" Text="Сохранить"  CssClass="button"/>&nbsp;
                <asp:Button ID="_cancelBtn" runat="server" OnClick="_cancelBtn_Click" Text="Отмена"  CssClass="button"/>
                <br />
                <br />
                <asp:Label  ID="_ImageLbl" Text="1" runat="server" ForeColor="#003300"></asp:Label> 
            </ContentTemplate>

            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="_addBtn" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="_cancelBtn" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="_editBtn" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="_deleteBtn" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="_saveBtn" EventName="Click" />
            </Triggers>
                            
        </asp:UpdatePanel>


                <asp:Label ID="_fileUploadLabel" runat="server" Text="Изображение груза" ForeColor="Gray"></asp:Label>
                <asp:FileUpload ID="FileUpload1" runat="server" />
        &nbsp;
        <asp:Button ID="_uploadBtn" runat="server" Text="Загрузить" OnClick="Button1_Click" CssClass="button" />

        <asp:ObjectDataSource ID="CargoDetailODS" runat="server" SelectMethod="GetCargoByCode"  TypeName="DigDes.DSchool.SUPS.DataAccess.Database.CargoDAC" InsertMethod="InsertCargo" OldValuesParameterFormatString="original_{0}" DeleteMethod="DeleteCargo" UpdateMethod="UpdateCargo">
            
            <DeleteParameters>
                <asp:Parameter Name="CodeGNG" Type="String" />
            </DeleteParameters>

            <InsertParameters>
                <asp:Parameter Name="CargoName" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="Code" Type="String" />
                <asp:Parameter Name="CodeETSNG" Type="String" />
                <asp:Parameter Name="CargoETSNGName" Type="String" />
                <asp:Parameter Name="CodeGNG" Type="String" />
                <asp:Parameter Name="CodeGNGName" Type="String" />
                <asp:Parameter Name="Mnemocode" Type="String" />
                <asp:Parameter Name="Image" Type="Object" />
            </InsertParameters>

            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" DefaultValue="NULL" Name="Code" PropertyName="SelectedValue" Type="String" />
            </SelectParameters>

            <UpdateParameters>
                <asp:Parameter Name="CargoName" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="Code" Type="String" />
                <asp:Parameter Name="CodeETSNG" Type="String" />
                <asp:Parameter Name="CargoETSNGName" Type="String" />
                <asp:Parameter Name="CodeGNG" Type="String" />
                <asp:Parameter Name="CodeGNGName" Type="String" />
                <asp:Parameter Name="Mnemocode" Type="String" />
            </UpdateParameters>
        </asp:ObjectDataSource>    
    </div>
</body>
</html>
    </asp:Content>